import 'dart:collection';

import 'package:dailoz/views/add_page.dart';
import 'package:dailoz/views/analyze_page.dart';
import 'package:dailoz/views/home_page.dart';
import 'package:dailoz/views/profile_page.dart';
import 'package:dailoz/views/task_page.dart';
import 'package:flutter/material.dart';

class PageData extends ChangeNotifier {
  final List _pageList = [
    const HomePage(),
    const TaskPage(),
    const AddPage(),
    const AnalyzePage(),
    const ProfilePage(),
  ];

  int _index = 0;

  int _num = 0;

  String? _userName = "";

  Locale _language = const Locale("zh", "CN");

  String? _languageName = "中文";

  String get languageName {
    return _languageName!;
  }

  int get num {
    return _num;
  }

  Locale? get language {
    return _language;
  }

  UnmodifiableListView get pageList {
    return UnmodifiableListView(_pageList);
  }

  List get list {
    return _pageList;
  }

  int get index {
    return _index;
  }

  String? get userName {
    return _userName;
  }

  void changeName(name) {
    _languageName = name;
    notifyListeners();
  }

  void change(int n) {
    _num = n;
    notifyListeners();
  }

  void changeLanguage(Locale language) {
    _language = language;
    notifyListeners();
  }

  void increment(int num) {
    _index = num;
    notifyListeners(); // 通知听众刷新
  }

  void setUserName(String? name) {
    _userName = name;
    notifyListeners();
  }

  void remove() {
    _index = 0;
    _userName = "";
    notifyListeners();
  }
}
